import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class VendingMachineItemTest {

        
        VendingMachineItem twizzlers, fruitsnacks, peanuts,chips; 
                
        private final static String PRICE_LESS_THAN_ZERO_MESSAGE = "Price cannot be less than zero";
        @Before
        public void setUp() throws Exception {
                fruitsnacks = new VendingMachineItem("fruit snacks", 1.25);
                peanuts = new VendingMachineItem("",0);
                chips = new VendingMachineItem("",2);
                
        }

        @After
        public void tearDown() throws Exception {
        }

        /**
         * testVendingMachineItem
         * This test checks to see that a VendingMachineItem that has been created
         * has a price greater than or equal to 0.
         */
        @Test
        public void testVendingMachineItem() {
                assertTrue(((fruitsnacks.getPrice())>=0));
                
        }
        
        /**
         * testVendingMachineItem2
         * This test checks to see if the price of a VendingMachineItem is negative
         * (this should not be allowed.) It should return an error if the item has a 
         * negative price. 
         */
        @Test
        public void testVendingMachineItem2() {
                VendingMachineItem coke = new VendingMachineItem("coke",(1.5));
                double cokePrice = 0;
                cokePrice = coke.getPrice();
                System.out.println("This is the price of the coke:"+cokePrice);
                
                
                assertTrue(coke.getPrice()>=0);
                
        }
        //@Test
        public void testVendingmachineItem3()throws VendingMachineException{
        	VendingMachineItem sprite = new VendingMachineItem("sprite",-55.00);
        	
        	double spritePrice = sprite.getPrice();
        	//assertEquals(0,sprite.getPrice());
        	//assertTrue(spritePrice<0);
        	//if (spritePrice < 0)
        		//throw new VendingMachineException(PRICE_LESS_THAN_ZERO_MESSAGE);
        	System.out.println("Error, price cannot be "+spritePrice);
        	
       }
        /**
         * testGetName
         * This test checks to see that the function getName()
         * will return the name of the vending machine item. 
         */
        @Test
        public void testGetName() {
                assertEquals("fruit snacks", fruitsnacks.getName());
        }
        
        /**
         * testGetName2
         * This test will check to see if the getName() function
         * will return correctly if a vending machine item has a 
         * String name of "". There is not currently anything in the 
         * code to keep you from entering a name with no
         * characters like this. 
         */
        @Test
        public void testGetName2(){
                assertEquals("",chips.getName());
                System.out.println("The name of chips is:"+chips.getName());
        }
        
        /**
         * testGetPrice
         * This test checks to see that the function getPrice()
         * returns the correct price of a vending machine item
         */
        @Test
        public void testGetPrice() {
                System.out.println("The price of the chips: "+chips.getPrice());
        
        /**
         * testGetPrice2
         * This test checks to see what will happen when an item has 
         * a negative price. This should produce an error.      
         */
        }
        @Test
        public void testGetPrice2() {
                twizzlers = new VendingMachineItem("twizzlers",2);
                System.out.println("The price of the twizzlers: "+twizzlers.getPrice());
                        
        }
        
        /**
         * testGetPrice3
         * This test checks to see if a vending machine item is given 
         * a price with extra zeros than standard US currency, would it 
         * equal the price of one with the standard 2 zeros. 
         */
        @Test
        public void testGetPrice3(){
                twizzlers = new VendingMachineItem("twizzlers",2.00000);
                System.out.println("Price of twizzlers: $"+twizzlers.getPrice());
                assertEquals(2.00,twizzlers.getPrice(),0);
        }
        /**
         * testGetPrice4
         * This test checks to see if a vending machine item is given 
         * a price of 2.444, would it equal a price of 2.44. They should 
         * not be equal. 
         */
        @Test
        public void testGetPrice4(){
                twizzlers = new VendingMachineItem("",2.444);
                if (2.44 !=(twizzlers.getPrice()))
                        {
                        System.out.println("Not equal");
                        }
                        
        }
        @Test
        public void testGetPrice5(){
        	twizzlers = new VendingMachineItem("",2.44);
            if (2.44 ==(twizzlers.getPrice()))
                    {
                    System.out.println("Equal!");
                    }
           
        }
}
